package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
	"strings"
	"sync"
)

var dmp map[string]int

func main() {
	wordmapfile, _ := os.Open("xx.file")
	scanner := bufio.NewScanner(wordmapfile)
	damap := make(map[string]int)
	dmp = damap
	var a = 0
	for scanner.Scan() {
		word := scanner.Text()
		damap[word] = a
		a++
	}

	scanner = bufio.NewScanner(os.Stdin)
	var zongre [][]int
	var wg sync.WaitGroup
	var l sync.Mutex
	for scanner.Scan() {
		filepath := scanner.Text()
		wg.Add(1)
		go func(filepath string) {
			re := doonefile(filepath)
			fmt.Println(filepath, "[..ok..]")
			l.Lock()
			zongre = append(zongre, re...)
			l.Unlock()
			wg.Done()
		}(filepath)
	}
	wg.Wait()
	printall(zongre)
}
func printall(zongre [][]int) {
	for _, v := range zongre {
		for _, vv := range v {
			fmt.Print(vv, " ")
		}
		fmt.Println()
	}
}
func dooneline(raw string, re []int) {
	segs := strings.Split(raw, `;`)
	for _, v := range segs {
		if len(v) == 0 {
			continue
		}
		xiaoseg := strings.Split(v, ` `)
		word := xiaoseg[0]
		number, _ := strconv.ParseInt(xiaoseg[1], 10, 0)
		myindex := dmp[word]
		re[myindex] = int(number)
	}
}
func doonefile(filepath string) [][]int {
	rezong := make([][]int, 0, 0)
	docfile, _ := os.Open(filepath)
	scanner := bufio.NewScanner(docfile)
	for scanner.Scan() {
		oneline := scanner.Text()
		re := make([]int, 10, 10)
		dooneline(oneline, re)
		rezong = append(rezong, re)
	}
	return rezong
}
